  function plot2cal(cal,mat,sernames,flag_nofig)
% ==================================================================  
% function plot2cal(cal,mat,sernames)
% PLOT2CAL Plot up to six series in mat with a calendar on the X axis 
% CAL           [nobs 1] 
% MAT           [nobs nx] 
% SERNAMES      (Optional) Cell with names in Mat 
% Alejandro Justiniano  July 7 2007 
% ===================================================================
cal=cal(:);
nobs=length(cal);
[ch nx]=size(mat);
if ch~=nobs;error('MAT must have as many rows as the calendar');end;
if nargin < 4 
    flag_nofig=0; 
else 
    if flag_nofig~=1 && flag_nofig~=0 
        error('flag_nofig must be 1 or 0') 
    end 
end 
if nargin < 3 || isempty(sernames); 
    sernames=fnumcell('ser',[1:nx]);
else
    if length(sernames)~=nx
        error('SERNAMES must match number of coluns in MAT')
    end
end
style={ 'b-','--r',':k','g.-','r*:','kx--' };
width=[2.5 3 4 3.5 1.5 2]; 
if flag_nofig==0
    figure;
end
for ii=1:nx; 
    plot(cal,mat(:,ii),style{ii},'LineWidth',width(ii)) 
    if ii==1 
        hold on; 
    end 
end 
hh=legend(sernames,'Location','Best'); 
set(hh,'EdgeColor','w'); 
axis tight;
hold off; 